﻿@{
    Bundle("jquery_rateit");
    Layout = "../Shared/_Default.cshtml";
    ViewBag.PageTitle = T(Res.Name("Title"), JDM.String(Model.SKU));
    ViewBag.PageHistory = true;
}

@section Breadcrumb
{
    @{
        Html.RenderPartial("_Breadcrumb", (object)Model.CatalogItem.Categories);
    }
}
@section Toolbar
{
    <a href="@Url.Action(Loc.Act("Show").Ctrl("Item").Area("Catalog").Set(new
    {
        id = JDM.Int32(Model.CatalogItem.EntityID)
    }).Localized())">@T(Res.Name("Catalog"))</a>
}
@section Sidebar
{
    <div class="box">
        <section>
            <div class="rating">
                <div class="rateit" data-rateit-readonly="true" data-rateit-ispreset="false" data-rateit-value="@JDM.Byte(Model.CatalogItem.RatingAverage)"></div>
                <p>@T(Res.Name("Stat"), JDM.Byte(Model.CatalogItem.RatingAverage), JDM.Byte(Model.CatalogItem.RatingCount), JDM.Byte(Model.CatalogItem.CommentCount))</p>
            </div>
        </section>
    </div>
    <div class="box">
        <header>
            <h3>@T(Res.Name("Purchase"))</h3>
        </header>
        <section>
        @{
            Html.RenderPartial("_BuyForm");
            Html.RenderPartial("_Stock");
        }
        </section>
    </div>
    @{
        Html.RenderAction(Loc.Act("_Overview").Ctrl("Seller").Set(new
        {
            id = JDM.Int32(Model.Seller.EntityID)
        }).Localized());
        Html.RenderAction(Loc.Act("_Overview").Ctrl("Supplier").Area("Catalog").Set(new
        {
            id = JDM.Int32(Model.CatalogItem.Supplier.EntityID)
        }).Localized());
    }
}
<div class="box @(JDM.HasFlags(Model.CatalogItem.Flags, "Promoted") ? "promoted" : String.Empty) @(!JDM.HasFlags(Model.Flags, "Active") ? "inactive" : String.Empty)">
    <section>
        <table class="columned">
            <tbody>
                <tr>
                    <td>
                    @{
                        Html.RenderPartial("_Image", (object)Model.CatalogItem);
                    }
                    </td>
                    <td style="width: 100%;">
                    @{
                        Html.RenderPartial("_ShortDescription", (object)Model.CatalogItem);
                        var attrs = Model.CatalogItem.Attributes as IEnumerable<dynamic>;
                        if(attrs.Any())
                        {
                            Html.RenderPartial("_Attributes", attrs);
                        }
                    }
                    </td>
                </tr>
            </tbody>
        </table>
    </section>
    <section>
    @{
        Html.RenderPartial("_Description", (object)Model.CatalogItem);
    }
    </section>
</div>
